package com.tvunetworks.center.device.controller;

import com.tvunetworks.center.common.model.param.PeerIdParam;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.common.util.ResultUtil;
import com.tvunetworks.center.device.model.param.SetManualParam;
import com.tvunetworks.center.device.service.DeviceExtraService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @program: tvucc-aggregator
 * @description: DeviceExtraController
 * @author lebronchen
 * @create: 2020-03-13 08:30
 **/
@RestController
@RequestMapping("/deviceExtra")
@Slf4j
public class DeviceExtraController {

    @Autowired
    private DeviceExtraService deviceExtraService;

    /**
     * 设置设备手动/自动
     * @param param param
     * @return success
     */
    @PostMapping("/setManual")
    public Result setManual(@RequestBody SetManualParam param) {
        deviceExtraService.setManual(param);
        return ResultUtil.success();
    }

    /**
     * 查询设备是否是自动
     * @param param param
     * @return isManual
     */
    @PostMapping("/isManual")
    public Result isManual(@RequestBody @Valid PeerIdParam param) {
        boolean isManual = deviceExtraService.isDeviceManual(param.getPeerId());
        return ResultUtil.success(isManual);
    }
}
